//Name: Cao Dung Anh
//Class: 11CTT
//Sid: 1151003

#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
#include "BookInfo.h"
#include <iomanip>

void BookInfo::addBook()
{
	int c=1;
	do
	{   cout << "ISBN: ";
		cin.getline(this->ISBN,sizeof(this->ISBN));
		if(this->checkISBN()==false)
		{
			cout << "Wrong input!"<<endl;
			c=0;
		}
	}while(c==0);
	cout << "Name: ";
	cin.getline(this->Name,sizeof(this->Name));
	cout << "Kind: ";
	cin.getline(this->Kind,sizeof(this->Kind));
	cout << "AuthorName: ";
	cin.getline(this->AuthorName,sizeof(this->AuthorName));
	cout << "Publisher: ";
	cin.getline(this->Publisher,sizeof(this->Publisher));
	cout << "Year of publication: ";
	cin >> this->YoP;
	cout << "Number of this book: ";
	cin >> this->stock;
}

void BookInfo::addBook(char *ISBN)
{
	strcpy(this->ISBN,ISBN);
	cout << "Name: ";
	cin.getline(this->Name,sizeof(this->Name));
	cout << "Kind: ";
	cin.getline(this->Kind,sizeof(this->Kind));
	cout << "AuthorName: ";
	cin.getline(this->AuthorName,sizeof(this->AuthorName));
	cout << "Publisher: ";
	cin.getline(this->Publisher,sizeof(this->Publisher));
	cout << "Year of publication: ";
	cin >> this->YoP;
	cout << "Number of this book: ";
	cin >> this->stock;
	cin.get();
}

void BookInfo::copyBook(BookInfo b)
{
	strcpy(this->ISBN,b.ISBN);
	strcpy(this->Name,b.Name);
	strcpy(this->Kind,b.Kind);
	strcpy(this->AuthorName,b.AuthorName);
	strcpy(this->Publisher,b.Publisher);
	this->YoP = b.YoP;
	this->stock = b.stock;
}

char* BookInfo::getName()
{
	return this->Name;
}

//show all information of a book
void BookInfo::showBook()
{
	cout << "ISBN:                " << this->ISBN << endl;
	cout << "Name:                " << this->Name << endl;
	cout << "Kind:                " << this->Kind << endl;
	cout << "AuthorName:          " << this->AuthorName << endl;
	cout << "Publisher:           " << this->Publisher << endl;
	cout << "Year of Publication: " << this->YoP << endl;
	cout << "Number of Book:      " << this->stock << "\n\n";
}	

char* BookInfo::getType()
{
	return this->Kind;
}

char* BookInfo::getISBN()
{
	return this->ISBN;
}

int BookInfo::getStock()
{
	return this->stock;
}

int BookInfo::getYoP()
{
	return this->YoP;
}

//Set the number of book
void BookInfo::setStock(int n)
{
	this->stock = n;
}
//Get the author name
char* BookInfo::getAuthorName()
{
	return this->AuthorName;
}

//Get the Publisher
char* BookInfo::getPublisher()
{
	return this->Publisher;
}

//check ISBN
bool BookInfo::checkISBN()
{
	if(strlen(this->ISBN)!=13)
		return false;
	else
		return true;
}